home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: memory allocation using malloc and free
- Date: 22 Feb 96 01:28:12 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.824952492@rscernix>
- References: <4gagll$5rc@bertrand.ccs.carleton.ca> <danpop.824767980@rscernix> <4gbqd7$1em@inet-nntp-gw-1.us.oracle.com> <4gd8ngINNp5i@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <4gd8ngINNp5i@keats.ugrad.cs.ubc.ca> c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
-
- >In article <4gbqd7$1em@inet-nntp-gw-1.us.oracle.com>,
- >William Kaufman <wkaufman@wkaufman.us.oracle.com> wrote:
- > >In article <danpop.824767980@rscernix> danpop@mail.cern.ch (Dan Pop) writes:
- > >] In <4gagll$5rc@bertrand.ccs.carleton.ca> tcope@chat.carleton.ca (Tyler Cope) writes:
- > >]
- > >] >Could someone please demonstrate the proper (or _a_ proper) ANSI
- > >] >method of allocating >64K space using malloc and free.
- > >[...]
- > >]
- > >] The usual workaround on unextended MSDOS is to use vendor-specific
- > >] functions which take long or unsigned long arguments. Of course, this
- > >] has nothing to do with ANSI C any longer.
- > >
- > > One work-around which _is_ ANSI C would be to break the allocation
- > >down into a two-dimensional array where each dimension is less than 64K.
- > >The memory won't be continguous anymore, but this is often not a severe
- > >restriction. And, it's portable.
-
- It depends on what you mean by "portable". ANSI doesn't even guarantee
- that you can get a single 64k block via malloc (or using static allocation).
-
- >But can a compiler which restricts size_t to 16-bits a be a strictly conforming
- >implementation? (I don't have the standard documents yet, so I'm forced to
- >ask).
-
- Yes.
-
- >If 16-bit size_t is admitted within the limitations of the standard, it
- >means that a strictly conforming program has to robustly accomodate itself on
- >such crippled architectures. I know that ANSI has some bottom limits on what
- >can be considered a viable architecture to host the C language, but what are
- >those limits?
-
- For this particular discussion, the limit is 32K - 1. And no more than
- one object of this size. (Actually the phrasing is a little bit silly,
- because it doesn't even guarantee that every program containing such an
- object can be compiled and run, it requires that at least one program
- should be correctly translated):
-
- 2.2.4.1 Translation limits
-
- The implementation shall be able to translate and execute at least
- one program that contains at least one instance of every one of the
- following limits:
- ...
- * 32767 bytes in an object (in a hosted environment only)
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-